﻿using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace WebApplication1
{
    [Route("[controller]")]
    [ApiController]
    public class TestController : ControllerBase
    {
        private readonly IServer _server;
        public TestController(IServer server)
        {
            _server = server;
        }

        [HttpGet]
        public string Get()
        {
            var addresses = _server.Features.Get<IServerAddressesFeature>().Addresses;
            var str = $"ip：{string.Join(", ", addresses)}，环境：{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}";
            return str;
        }
    }
}
